package cn.fan.utils;

import cn.fan.constants.TokenConstants;
import org.springframework.util.StringUtils;

import javax.servlet.http.HttpServletRequest;

public class UserUtils {

    // 更新（添加、删除、获取）失败
    public static final int FAIL = -1;

    public static Long getSysUserId(){
        HttpServletRequest request = ServletUtils.getRequest();
        String userId = request.getHeader(TokenConstants.USER_ID);

        return StringUtils.hasText(userId) ? Long.parseLong(userId) : FAIL;
    }

}
